List of Conquests
T=input()
arr=[]
for t in range(int(T)):
a=list(input().split())
arr.append(a[0])
dic={}
for i in arr:
if i not in dic:
dic[i]=1
else:
dic[i]+=1
ans=sorted(dic.items(),key=lambda x:x[0])
ans=sorted(ans,key=lambda x:x[1])
for x,y in ans:
print('{} {}'.format(x,y))
What's Cryptanalysis
T=input()
arr=[]
for t in range(int(T)):
arr+=list(input())
dic={}
for i in arr:
i=i.upper()
if str.isalpha(i):
if i not in dic:
dic[i]=1
else:
dic[i]+=1
ans=sorted(dic.items(),key=lambda x:x[0])
ans=sorted(ans,key=lambda x:x[1],reverse=1)
for x,y in ans:
print('{} {}'.format(x,y))